global background, hero, obstacles, hit, projector
if projector then
move(background)
end if
move(hero)
repeat with i = 1 to count(obstacles)
move(getAt(obstacles, i))
end repeat
set the loc of sprite hit to point(-100, -100)
checkCollision(me)
Distance = Distance + 1
if Distance > (1500 + (500 * levelNum)) then
action = "levelDone"
endLevel(hero)
end if
end
on checkCollision me
global hero, obstacles
repeat with i = 1 to count(obstacles)
if (the locV of sprite hero.sNumber > the locV of sprite getAt(obstacles, i).sNumber) and (getAt(obstacles, i).action = "alive") then
if sprite hero.sNumber intersects getAt(obstacles, i).sNumber and (abs(the locH of sprite hero.sNumber - the locH of sprite getAt(obstacles, i).sNumber) < 25) then
hit(getAt(obstacles, i))
exit repeat
end if
end if
end repeat
end
on calcDamage me, howMuch
global damage, sDamage, hero
damage = damage + howMuch
set the rect of sprite sDamage to rect(35, 75 - damage, 67, 75)
if damage >= 71 then
damage = 71
set the rect of sprite sDamage to rect(35, 4, 67, 75)
if hero.action <> "dead" then
die(hero)
end if
end if
if damage <= 0 then
damage = 0
set the rect of sprite sDamage to rect(35, 75, 67, 75)
end if
end
on turnOff me
repeat with i = 1 to count(obstacles)
turnOff(getAt(obstacles, i))
end repeat
end
on initLevel me
levelNum = levelNum + 1
level = levelNum
Distance = 0
action = "play"
end
on moveToFinished me
global background, hero, obstacles, hit
if background.vIncr > 0 then
background.vIncr = background.vIncr - 0.5
end if
repeat with i = 1 to count(obstacles)
getAt(obstacles, i).vIncr = background.vIncr
move(getAt(obstacles, i))
end repeat
move(background)
moveToFinished(hero)
set the loc of sprite hit to point(-100, -100)
end
on calcScore me, whichToad
case whichToad of
1:
put value(field("toad1score")) + 1 into field "toad1score"
2:
put value(field("toad2score")) + 1 into field "toad2score"
3:
put value(field("toad3score")) + 1 into field "toad3score"
end case
end
on startRepairs me
turnOff(me)
maxtoad1 = value(field("toad1score"))
maxtoad2 = value(field("toad2score"))
maxtoad3 = value(field("toad3score"))
repeat with i = 1 to 48
set the visible of sprite i to 1
end repeat
end
on moreRepairs me
if value(field("toad3score")) <= 0 then
if value(field("toad2score")) <= 0 then
if value(field("toad1score")) <= 0 then
else
put value(field("toad1score")) - 1 into field "toad1score"
calcDamage(me, -0.25)
end if
else
put value(field("toad2score")) - 1 into field "toad2score"
calcDamage(me, -0.5)
end if
else
put value(field("toad3score")) - 1 into field "toad3score"
calcDamage(me, -1)
end if
end
on lessRepairs me
if value(field("toad1score")) >= maxtoad1 then
if value(field("toad2score")) >= maxtoad2 then
if value(field("toad3score")) >= maxtoad3 then
else
put value(field("toad3score")) + 1 into field "toad3score"
calcDamage(me, 1)
end if
else
put value(field("toad2score")) + 1 into field "toad2score"
calcDamage(me, 0.5)
end if
else
put value(field("toad1score")) + 1 into field "toad1score"
calcDamage(me, 0.25)
end if
end
on repair me
if ((value(field("toad1score")) = maxtoad1) and (value(field("toad2score")) = maxtoad2) and (value(field("toad3score")) = maxtoad3)) or (damage >= 71) then
set the visible of sprite 41 to 0
set the visible of sprite 43 to 0
else
set the visible of sprite 41 to 1
set the visible of sprite 43 to 1
end if
if ((value(field("toad1score")) = 0) and (value(field("toad2score")) = 0) and (value(field("toad3score")) = 0)) or (damage <= 0) then